package com.example.config.demo;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @author yuisama
 * @date 2023/02/01 16:05
 **/
@Slf4j
@Component
public class ReadFromConfig1 {
    private final Environment environment;
    
    @Autowired
    public ReadFromConfig1(Environment environment){
        this.environment = environment;

        String value = environment.getProperty("logging.file.name");
        log.info("读取到的 logging.file.name = "+ value);

        value = environment.getProperty("xiaojing.name");
        log.info("读取到的 xiaojing.name = "+ value);

        if("menmen".equals(value)){
            log.info("欢迎 门门");
        }else{
            log.info("欢迎新用户");
        }

        value = environment.getProperty("xiaojing.age");
        log.info("读取到的 menmen.age ="+ value);
    }

}

